package com.tms.app.tms.adapter;

import android.view.View;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.tms.app.tms.R;
import com.tms.app.tms.bean.TaskInfo;
import com.tms.app.tms.bean.TestBean;
import com.tms.app.tms.utils.TimeUtil;

import java.util.List;

/**
 * Created by happy on 2017/8/26.
 */

public class HistoryAdapter extends BaseQuickAdapter<TaskInfo, BaseViewHolder> {
    public HistoryAdapter() {
        super(R.layout.item_layout_task);
    }



    @Override
    protected void convert(BaseViewHolder helper, TaskInfo item) {
        helper.setText(R.id.text_task_status,item.getDoLineInfo());
        helper.setText(R.id.text_order_no,item.getAllotPlanNo());
        helper.setText(R.id.text_fee,item.getPrice()+"");
        helper.setText(R.id.text_time,"做箱时间："+ TimeUtil.getTimeFormat(item.getDoTime()+""));
        helper.setText(R.id.text_people,"调度人：" +item.getDispatchUser() +"  "+ item.getDispatchUserPhone());
        helper.setText(R.id.text_fabu_name,item.getCompanyName());
        helper.setText(R.id.text_fabu_time, TimeUtil.getTimeFormat(item.getPublishTime()+""));
        ImageView imageView =helper.getView(R.id.img_head);
        setBusiType(helper,item.getBusiType());
        Glide.with(imageView.getContext())
                .load(item.getCompanyImgSrc())
                .error(R.mipmap.default_c)
                .into(imageView);
        ProgressBar progressBar=helper.getView(R.id.item_progress);
        progressBar.setProgress(0);
        helper.getView(R.id.img_task_status).setVisibility(View.GONE);

    }

    private void setBusiType(BaseViewHolder helper,String ... type){
        TextView textView1=helper.getView(R.id.text_fabu_type1);
        TextView textView2=helper.getView(R.id.text_fabu_type2);
        TextView textView3=helper.getView(R.id.text_fabu_type3);

        textView1.setVisibility(View.GONE);
        textView2.setVisibility(View.GONE);
        textView3.setVisibility(View.GONE);

        for (String str : type) {
            String[] busiTypes=str.split(",");
            for (String type1 : busiTypes) {
                switch (type1){
                    case "0":
                        textView1.setVisibility(View.VISIBLE);
                        break;
                    case "1":
                        textView2.setVisibility(View.VISIBLE);
                        break;
                    case "2":
                        textView3.setVisibility(View.VISIBLE);
                        break;
                }
            }

        }
    }


}
